package com.bluefoxyu;

import org.opencv.core.Core;
import org.opencv.core.Mat;
import org.opencv.imgcodecs.Imgcodecs;
import org.opencv.imgproc.Imgproc;

public class test_ikun {

    public static void main(String[] args) {
        //加载 opencv_javaXX.dll
        System.loadLibrary(Core.NATIVE_LIBRARY_NAME);
        //测试图片地址
        String imgPath = "./ikun-demo/src/main/java/com/bluefoxyu/images/ikun.jpg";
        System.out.println("灰度前的图片绝对路径：" + imgPath);
        //灰度化
        //读取图片
        Mat img = Imgcodecs.imread(imgPath);
        //生成灰度图
        Mat gray = new Mat();
        Imgproc.cvtColor(img,gray, Imgproc.COLOR_BGR2GRAY);
        //保存图片
        String resultPath = "./ikun-demo/src/main/java/com/bluefoxyu/results/images/result.png";
        System.out.println("灰度后的图片绝对路径：" + resultPath);
        Imgcodecs.imwrite(resultPath, gray);
    }

}
